package flc.ast.activity;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.adapter.StarOverviewAdapter;
import flc.ast.bean.StarsBean;
import flc.ast.databinding.ActivityStarOverviewBinding;
import flc.ast.fragment.HomeFragment;
import stark.common.basic.event.EventStatProxy;

public class StarOverviewActivity extends BaseAc<ActivityStarOverviewBinding> {

    private List<StarsBean> listStar = new ArrayList<>();
    private StarOverviewAdapter starOverviewAdapter;

    @Override
    protected int onCreate() {
        return R.layout.activity_star_overview;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(this, mDataBinding.event1Container);

        mDataBinding.ivStarOverviewBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.rvStarList.setLayoutManager(new GridLayoutManager(mContext, 3));
        starOverviewAdapter = new StarOverviewAdapter();
        mDataBinding.rvStarList.setAdapter(starOverviewAdapter);
        starOverviewAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        HomeFragment.starsName = starOverviewAdapter.getItem(position).getName();
        finish();
    }

    @Override
    protected void initData() {
        listStar.add(new StarsBean(getString(R.string.star_sign11), R.drawable.spz, getString(R.string.birth_date11)));
        listStar.add(new StarsBean(getString(R.string.star_sign12), R.drawable.syz, getString(R.string.birth_date12)));
        listStar.add(new StarsBean(getString(R.string.star_sign1), R.drawable.byz, getString(R.string.birth_date1)));
        listStar.add(new StarsBean(getString(R.string.star_sign2), R.drawable.jnz, getString(R.string.birth_date2)));
        listStar.add(new StarsBean(getString(R.string.star_sign3), R.drawable.shuangzz, getString(R.string.birth_date3)));
        listStar.add(new StarsBean(getString(R.string.star_sign4), R.drawable.jxz, getString(R.string.birth_date4)));
        listStar.add(new StarsBean(getString(R.string.star_sign5), R.drawable.szz, getString(R.string.birth_date5)));
        listStar.add(new StarsBean(getString(R.string.star_sign6), R.drawable.cnz, getString(R.string.birth_date6)));
        listStar.add(new StarsBean(getString(R.string.star_sign7), R.drawable.tcz, getString(R.string.birth_date7)));
        listStar.add(new StarsBean(getString(R.string.star_sign8), R.drawable.txz, getString(R.string.birth_date8)));
        listStar.add(new StarsBean(getString(R.string.star_sign9), R.drawable.ssz, getString(R.string.birth_date9)));
        listStar.add(new StarsBean(getString(R.string.star_sign10), R.drawable.mxz, getString(R.string.birth_date10)));
        starOverviewAdapter.setList(listStar);
    }
}